/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_API_REFLECTION_NUMBER_HPP
#define	_CUBEFS_API_REFLECTION_NUMBER_HPP

#include <cubefs/api/reflection/value.hpp>

namespace cubefs    {
namespace api       {

struct CUBEFS_API Number: public Value {

    virtual Int     GetIntValue() const                 = 0;
    virtual UInt    GetUIntValue() const                = 0;

    virtual Byte    GetByteValue() const                = 0;
    virtual UByte   GetUByteValue() const               = 0;

    virtual Short   GetShortValue() const               = 0;
    virtual UShort  GetUShortValue() const              = 0;

    virtual BigInt  GetBigIntValue() const              = 0;

    virtual float   GetFloatValue() const               = 0;
    virtual double  GetDoubleValue() const              = 0;

	virtual void SetIntValue(Int value)          		= 0;
	virtual void SetUIntValue(UInt value)        		= 0;

	virtual void SetByteValue(Byte value)        		= 0;
	virtual void SetUByteValue(UByte value)      		= 0;

	virtual void SetShortValue(Short value)      		= 0;
	virtual void SetUShortValue(UShort value)    		= 0;

	virtual void SetBigIntValue(BigInt value)    		= 0;

	virtual void SetFloatValue(float value)      		= 0;
	virtual void SetDoubleValue(double value)    		= 0;

	virtual void SetValue(Int value)          			= 0;
	virtual void SetValue(UInt value)        			= 0;

	virtual void SetValue(Byte value)        			= 0;
	virtual void SetValue(UByte value)      			= 0;

	virtual void SetValue(Short value)      			= 0;
	virtual void SetValue(UShort value)    				= 0;

	virtual void SetValue(BigInt value)    				= 0;

	virtual void SetValue(float value)      			= 0;
	virtual void SetValue(double value)    				= 0;

	virtual Int Compare(const Number* number) const		= 0;

    static Type* MyType();
};

CUBEFS_DECLARE_TYPENAME(Number, "cubefs::api::Number");


template <typename T>
struct CUBEFS_API TypedNumber: public Number {

    virtual const T& GetValue() const 					= 0;
    virtual T& GetValue() 								= 0;
//    virtual void SetValue(T value) 						= 0;
    
    static Type* MyType() {
    	return GetTypedNumberType(TypeHash<T>::hash);
    }
};

CUBEFS_API Type* GetTypedNumberType(Int type_hash_code);

typedef TypedNumber<Byte> 	ByteNumber;
typedef TypedNumber<UByte> 	UByteNumber;
typedef TypedNumber<Short> 	ShortNumber;
typedef TypedNumber<UShort> UShortNumber;
typedef TypedNumber<Int> 	IntNumber;
typedef TypedNumber<UInt> 	UIntNumber;
typedef TypedNumber<BigInt> BigIntNumber;
typedef TypedNumber<float> 	FloatNumber;
typedef TypedNumber<double> DoubleNumber;

CUBEFS_DECLARE_PARAMETRIZED_TYPENAME(TypedNumber, "cubefs::api::TypedNumber");

}
}

#endif
